package com.yunkazaixian.syntelecom.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * Author:      gfl
 * Mail:        fuleiit@163.com
 * Date:        2024/2/18 15:22
 * Version:     1.0
 * Description:
 */

@Component
public class DeadLetterMQConfig {
    /**
     * 订单交换机
     */
    //  @Value("${rk.order.exchange}")
    private String orderExchange = "rk_llk_order_exchange";

    /**
     * 订单队列
     */
    // @Value("${rk.order.queue}")
    private String orderQueue = "rk_llk_order_queue";

    /**
     * 订单路由key
     */
    // @Value("${rk.order.routingKey}")
    private String orderRoutingKey = "order_llk";
    /**
     * 死信交换机
     */
    // @Value("${rk.dlx.exchange}")
    private String dlxExchange = "rk_llk_dlx_exchange";
    private String dlxSimExchange = "rk_llk_sim_dlx_exchange";
    private String dlxSimQueryExchange = "rk_llk_sim_query_dlx_exchange";
    private String dlxSimQueryMonthExchange = "rk_llk_sim_query_month_dlx_exchange";
    private String dlxSim5gCMPExchange = "rk_llk_sim_5gCMP_dlx_exchange";
    private String dlxSimRechargeExchange = "rk_llk_sim_Recharge_dlx_exchange";
    private String dlxSimOrderCancelExchange = "rk_llk_sim_order_cancel_dlx_exchange";
    // 会话开始与结束
    private String dlxSimSessionExchange = "rk_llk_sim_session_dlx_exchange";
    /**
     * 死信队列
     */
    // @Value("${rk.dlx.queue}")
    private String dlxQueue = "rk_llk_order_dlx_queue";
    /**
     * 死信路由
     */
    // @Value("${rk.dlx.routingKey}")
    private String dlxRoutingKey = "dlx_llk";
    private String dlxSimRoutingKey = "dlx_sim_llk";
    private String dlxSimQueryRoutingKey = "dlx_sim_query_llk";
    private String dlxSimQueryMonthRoutingKey = "dlx_sim_query_month_llk";
    private String dlxSim5gCMPRoutingKey = "dlx_sim_5gCMP_llk";
    private String dlxSimRechargeRoutingKey = "dlx_sim_Recharge_llk";
    private String dlxSimOrderCancelRoutingKey = "dlx_sim_order_cancel_llk";
    private String dlxSimSessionRoutingKey = "dlx_sim_session_llk";
    /**
     * 声明死信交换机
     * @return DirectExchange
     */
    @Bean
    public DirectExchange dlxExchange() {
        return new DirectExchange(dlxExchange);
    }
    @Bean
    public DirectExchange dlxSimExchange() {
        return new DirectExchange(dlxSimExchange);
    }
    @Bean
    public DirectExchange dlxSimQueryExchange() {
        return new DirectExchange(dlxSimQueryExchange);
    }
    @Bean
    public DirectExchange dlxSimQueryMonthExchange() {
        return new DirectExchange(dlxSimQueryMonthExchange);
    }
    @Bean
    public DirectExchange dlxSim5gCMPExchange() {
        return new DirectExchange(dlxSim5gCMPExchange);
    }
    @Bean
    public DirectExchange dlxSimRechargeExchange() {
        return new DirectExchange(dlxSimRechargeExchange);
    }
    @Bean
    public DirectExchange dlxSimOrderCancelExchange() {
        return new DirectExchange(dlxSimOrderCancelExchange);
    }
    @Bean
    public DirectExchange dlxSimSessionExchange() {
        return new DirectExchange(dlxSimSessionExchange);
    }
    /**
     * 声明死信队列
     * @return Queue
     */
    @Bean
    public Queue dlxQueue() {
        return new Queue(dlxQueue);
    }
    @Bean
    public Queue simQueue() {
        return new Queue("rk_llk_sim_package_dlx_queue");
    }
    @Bean
    public Queue simQueryQueue() {
        return new Queue("rk_llk_sim_query_dlx_queue");
    }
    @Bean
    public Queue simQueryMonthQueue() {
        return new Queue("rk_llk_sim_query_month_dlx_queue");
    }
    @Bean
    public Queue sim5gCMPQueue() {
        return new Queue("rk_llk_sim_5gCMP_dlx_queue");
    }
    @Bean
    public Queue simRechargeQueue() {
        return new Queue("rk_llk_sim_Recharge_dlx_queue");
    }
    @Bean
    public Queue simOrderCancelQueue() {
        return new Queue("rk_llk_sim_order_cancel_dlx_queue");
    }
    @Bean
    public Queue simSessionQueue() {
        return new Queue("rk_llk_sim_session_dlx_queue");
    }
    /**
     * 声明订单业务交换机
     * @return DirectExchange
     */
    @Bean
    public DirectExchange orderExchange() {
        return new DirectExchange(orderExchange);
    }
    @Bean
    public DirectExchange simExchange() {
        return new DirectExchange("rk_llk_sim_package_dlx_exchange");
    }
    @Bean
    public DirectExchange simQueryExchange() {
        return new DirectExchange("rk_llk_sim_count_query_dlx_exchange");
    }
    @Bean
    public DirectExchange simQueryMonthExchange() {
        return new DirectExchange("rk_llk_sim_count_query_month_dlx_exchange");
    }
    @Bean
    public DirectExchange sim5gCMPExchange() {
        return new DirectExchange("rk_llk_sim_count_5gCMP_dlx_exchange");
    }
    @Bean
    public DirectExchange simRechargeExchange() {
        return new DirectExchange("rk_llk_sim_count_Recharge_dlx_exchange");
    }
    @Bean
    public DirectExchange simOrderCancelExchange() {
        return new DirectExchange("rk_llk_sim_count_order_cancel_dlx_exchange");
    }
    @Bean
    public DirectExchange simSessionExchange() {
        return new DirectExchange("rk_llk_sim_conver_session_dlx_exchange");
    }
    /**
     * 声明订单队列
     * @return Queue
     */
    @Bean
    public Queue orderQueue() {
        // 订单队列绑定我们的死信交换机
        Map<String, Object> arguments = new HashMap<>(2);
        //死信交换机
        arguments.put("x-dead-letter-exchange", dlxExchange);
        //死信队列
        arguments.put("x-dead-letter-routing-key", dlxRoutingKey);
        return new Queue(orderQueue, true, false, false, arguments);
    }
    @Bean
    public Queue simPackageQueue() {
        // 订单队列绑定我们的死信交换机
        Map<String, Object> arguments = new HashMap<>(2);
        //死信交换机
        arguments.put("x-dead-letter-exchange", dlxSimExchange);
        //死信队列
        arguments.put("x-dead-letter-routing-key", dlxSimRoutingKey);
        return new Queue("rk_llk_sim_package_queue", true, false, false, arguments);
    }
    @Bean
    public Queue simQueryCountQueue() {
        // 订单队列绑定我们的死信交换机
        Map<String, Object> arguments = new HashMap<>(2);
        //死信交换机
        arguments.put("x-dead-letter-exchange", dlxSimQueryExchange);
        //死信队列
        arguments.put("x-dead-letter-routing-key", dlxSimQueryRoutingKey);
        return new Queue("rk_llk_sim_query_queue", true, false, false, arguments);
    }
    @Bean
    public Queue simQueryMonthCountQueue() {
        // 订单队列绑定我们的死信交换机
        Map<String, Object> arguments = new HashMap<>(2);
        //死信交换机
        arguments.put("x-dead-letter-exchange", dlxSimQueryMonthExchange);
        //死信队列
        arguments.put("x-dead-letter-routing-key", dlxSimQueryMonthRoutingKey);
        return new Queue("rk_llk_sim_query_month_queue", true, false, false, arguments);
    }

    @Bean
    public Queue sim5gCMPCountQueue() {
        // 订单队列绑定我们的死信交换机
        Map<String, Object> arguments = new HashMap<>(2);
        //死信交换机
        arguments.put("x-dead-letter-exchange", dlxSim5gCMPExchange);
        //死信队列
        arguments.put("x-dead-letter-routing-key", dlxSim5gCMPRoutingKey);
        return new Queue("rk_llk_sim_5gCMP_queue", true, false, false, arguments);
    }
    @Bean
    public Queue simRechargeCountQueue() {
        // 订单队列绑定我们的死信交换机
        Map<String, Object> arguments = new HashMap<>(2);
        //死信交换机
        arguments.put("x-dead-letter-exchange", dlxSimRechargeExchange);
        //死信队列
        arguments.put("x-dead-letter-routing-key", dlxSimRechargeRoutingKey);
        return new Queue("rk_llk_sim_Recharge_queue", true, false, false, arguments);
    }
    @Bean
    public Queue simOrderCancelCountQueue() {
        // 订单队列绑定我们的死信交换机
        Map<String, Object> arguments = new HashMap<>(2);
        //死信交换机
        arguments.put("x-dead-letter-exchange", dlxSimOrderCancelExchange);
        //死信队列
        arguments.put("x-dead-letter-routing-key", dlxSimOrderCancelRoutingKey);
        return new Queue("rk_llk_sim_order_cancel_queue", true, false, false, arguments);
    }
    @Bean
    public Queue simSessionConverQueue() {
        // 订单队列绑定我们的死信交换机
        Map<String, Object> arguments = new HashMap<>(2);
        //死信交换机
        arguments.put("x-dead-letter-exchange", dlxSimSessionExchange);
        //死信队列
        arguments.put("x-dead-letter-routing-key", dlxSimSessionRoutingKey);
        return new Queue("rk_llk_sim_session_queue", true, false, false, arguments);
    }
    /**
     * 绑定死信队列到死信交换机
     * @return Binding
     */
    @Bean
    public Binding binding(Queue dlxQueue,DirectExchange dlxExchange) {
        return BindingBuilder.bind(dlxQueue).to(dlxExchange).with(dlxRoutingKey);
    }
    @Bean
    public Binding simBinding(Queue simQueue,DirectExchange dlxSimExchange) {
        return BindingBuilder.bind(simQueue).to(dlxSimExchange).with(dlxSimRoutingKey);
    }
    @Bean
    public Binding simQueryBinding(Queue simQueryQueue,DirectExchange dlxSimQueryExchange) {
        return BindingBuilder.bind(simQueryQueue).to(dlxSimQueryExchange).with(dlxSimQueryRoutingKey);
    }
    @Bean
    public Binding simQueryMonthBinding(Queue simQueryMonthQueue,DirectExchange dlxSimQueryMonthExchange) {
        return BindingBuilder.bind(simQueryMonthQueue).to(dlxSimQueryMonthExchange).with(dlxSimQueryMonthRoutingKey);
    }
    @Bean
    public Binding sim5gCMPBinding(Queue sim5gCMPQueue,DirectExchange dlxSim5gCMPExchange) {
        return BindingBuilder.bind(sim5gCMPQueue).to(dlxSim5gCMPExchange).with(dlxSim5gCMPRoutingKey);
    }
    @Bean
    public Binding simRechargeBinding(Queue simRechargeQueue,DirectExchange dlxSimRechargeExchange) {
        return BindingBuilder.bind(simRechargeQueue).to(dlxSimRechargeExchange).with(dlxSimRechargeRoutingKey);
    }
    @Bean
    public Binding simOrderCancelBinding(Queue simOrderCancelQueue,DirectExchange dlxSimOrderCancelExchange) {
        return BindingBuilder.bind(simOrderCancelQueue).to(dlxSimOrderCancelExchange).with(dlxSimOrderCancelRoutingKey);
    }
    @Bean
    public Binding simSessionBinding(Queue simSessionQueue,DirectExchange dlxSimSessionExchange) {
        return BindingBuilder.bind(simSessionQueue).to(dlxSimSessionExchange).with(dlxSimSessionRoutingKey);
    }
    /**
     * 绑定订单队列到订单交换机
     * @return Binding
     */
    @Bean
    public Binding orderBinding(Queue orderQueue, DirectExchange orderExchange) {
        return BindingBuilder.bind(orderQueue).to(orderExchange).with(orderRoutingKey);
    }
    @Bean
    public Binding simPackageBinding(Queue simPackageQueue, DirectExchange simExchange) {
        return BindingBuilder.bind(simPackageQueue).to(simExchange).with("sim_package_llk");
    }
    @Bean
    public Binding simQueryCountBinding(Queue simQueryCountQueue, DirectExchange simQueryExchange) {
        return BindingBuilder.bind(simQueryCountQueue).to(simQueryExchange).with("sim_query_llk");
    }
    @Bean
    public Binding simQueryMonthCountBinding(Queue simQueryMonthCountQueue, DirectExchange simQueryMonthExchange) {
        return BindingBuilder.bind(simQueryMonthCountQueue).to(simQueryMonthExchange).with("sim_query_month_llk");
    }
    @Bean
    public Binding sim5gCMPCountBinding(Queue sim5gCMPCountQueue, DirectExchange sim5gCMPExchange) {
        return BindingBuilder.bind(sim5gCMPCountQueue).to(sim5gCMPExchange).with("sim_5gCMP_llk");
    }
    @Bean
    public Binding simRechargeCountBinding(Queue simRechargeCountQueue, DirectExchange simRechargeExchange) {
        return BindingBuilder.bind(simRechargeCountQueue).to(simRechargeExchange).with("sim_Recharge_llk");
    }
    @Bean
    public Binding simOrderCancelCountBinding(Queue simOrderCancelCountQueue, DirectExchange simOrderCancelExchange) {
        return BindingBuilder.bind(simOrderCancelCountQueue).to(simOrderCancelExchange).with("sim_order_cancel_llk");
    }
    @Bean
    public Binding simSessionConverBinding(Queue simSessionConverQueue, DirectExchange simSessionExchange) {
        return BindingBuilder.bind(simSessionConverQueue).to(simSessionExchange).with("sim_session_llk");
    }
}
